<template>
	<view class="fz-head" >
		<image :src="bcimgUrl" class="ic-back" @click="backfn"></image>
		<text class="toptitle">{{title}}</text>
	</view>
</template>
<script>
	export default {
		name: "header",
		data() {
			return {};
		},
		props: {
			title: {
				type: String,
				default: '默认标题'
			},
			bcimgUrl: {
				type: String,
				default: '/static/docmumentImg/ic-back.png'
			},
		},
		methods: {
			// 返回按钮回调函数
			backfn() {
				// 获取当前页面栈
				const pages = getCurrentPages();
				// 获取当前页面对象
				const currentPage = pages[pages.length - 1];
				// 获取当前页面的路由路径
				const route = currentPage.route;
				const arr = route.split(('/'))
				const url = arr.splice(-1)
				if (url[0] === 'list') {
					window.native.close()
				} else if(url[0] === 'index' || url[0] === 'notice'){
					window.native.close()
				} else {
					this.$emit('backfn')
				}
			}
		}
	}
</script>
<style lang="scss">
	.fz-head {
		width: 100%;
		height: 88rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		background: #2d75d7;
		color: #fff;
		position: absolute;
		top: 0;
		justify-content: center;
		z-index: 9999;

		.ic-back {
			position: absolute;
			left: 30rpx;
			width: 48rpx;
			height: 48rpx;
		}

		.toptitle {
			font-size: 34rpx;
		}
	}
</style>